package com.zjp.service.impl;

import com.zjp.mapper.AreaMapper;
import com.zjp.mapper.CityMapper;
import com.zjp.mapper.ProvinceMapper;
import com.zjp.pojo.*;
import com.zjp.service.AreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
/**
 * 接种地址接口实现
 */
@Service
public class AreaServiceImpl implements AreaService {
    @Autowired
    private ProvinceMapper provinceMapper;

    @Autowired
    private CityMapper cityMapper;

    @Autowired
    private AreaMapper areaMapper;


    public List<Province> findAllProvince() {
        //查找所有省
        return provinceMapper.selectByExample(null);
    }


    public List<City> findCityByProvince(String provinceid) {
        //根据省id查找市
        CityExample example=new CityExample();
        CityExample.Criteria criteria=example.createCriteria();
        criteria.andFatherEqualTo(provinceid);
        return cityMapper.selectByExample(example);
    }


    public List<Area> findAreaByCity(String cityid) {
        //根据市id查找区
        AreaExample example=new AreaExample();
        AreaExample.Criteria criteria=example.createCriteria();
        criteria.andFatherEqualTo(cityid);
        return areaMapper.selectByExample(example);
    }


    public List<City> findAllCity() {
        //查找所有市
        return cityMapper.selectByExample(null);
    }


    public List<Area> findAllArea() {
        //查找所有区
        return areaMapper.selectByExample(null);
    }

}
